/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 17655
 * Date: 2025-05-22
 * Time: 18:56
 */
public class test1 {
    public static int findNum(int[] nums,int target){
        int left = 0;
        int right = nums.length-1;
        while(left<right){
            int mid = left + (right-left)/2;
            if(nums[mid] == target){
                return mid;
            }else if(nums[mid]>target){
                right = mid;
            }else{
                left = mid+1;
            }
        }
        return left;
    }

    public static void main(String[] args){
        int[] nums = {1,3,5,6};
        int target = 2;
        System.out.println(findNum(nums,target));
    }
}
